package com.imau.controller;


import com.alibaba.fastjson.JSON;
import com.imau.bean.PageEntitry;
import com.imau.bean.Student;
import com.imau.service.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/student/*")
public class StudentController extends BaseController {

    private StudentServiceImpl studentService= new StudentServiceImpl();


    protected void list(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
        req.setCharacterEncoding("utf-8");
        resp.setContentType(("text/html;charset=utf-8"));
        String currentPage=req.getParameter("currentPage");
        String pageSize=req.getParameter("pageSize");

        String jsonQuery = req.getReader().readLine();
        Student student= JSON.parseObject(jsonQuery,Student.class);
        PageEntitry<Student> pageEntitry=studentService.selectPageByCondition(Integer.valueOf(currentPage),Integer.valueOf(pageSize),student);
        this.writeJson(resp,pageEntitry,true);
    }

}
